package com.cljz.peipei.present.activity;

import com.cljz.peipei.base.BaseP;
import com.cljz.peipei.model.net.api.Api;
import com.cljz.peipei.model.net.bean.ResponseBean;
import com.cljz.peipei.ui.activity.BindphoneActivity;

import cn.droidlover.xdroidmvp.net.ApiSubcriber;
import cn.droidlover.xdroidmvp.net.NetError;
import cn.droidlover.xdroidmvp.net.XApi;

/**
 * Created by Administrator on 2017/5/2 0002.
 */
public class BindP extends BaseP<BindphoneActivity> {
    public void sendSmsCode(String phone) {
        Api.getResponseInfoAPI().sendSmsData(phone, "sms_login")
                .compose(XApi.<ResponseBean>getApiTransformer())
                .compose(XApi.<ResponseBean>getScheduler())
                .compose(getV().<ResponseBean>bindToLifecycle())
                .subscribe(new ApiSubcriber<ResponseBean>() {
                    @Override
                    protected void onFail(NetError error) {
                    }

                    @Override
                    public void onNext(ResponseBean sendSmsCodeBean) {
                        if ("0".equals(sendSmsCodeBean.getCode())) {
                            getV().sendSmsSucceed(sendSmsCodeBean);
                        } else {
                            getV().sendSmsFail(sendSmsCodeBean.getMsg());
                        }
                    }
                });

    }

}
